//
//  UIViewController+ShowImage.swift
//  ImagePicker
//
//  Created by Lj on 2019/10/5.
//  Copyright © 2019 Less. All rights reserved.
//

import UIKit

extension UIViewController {
    
    public func showAlertController(_ title: String = "", message: String = "", preferredStyle: UIAlertController.Style = .alert, actionTitles: [String], complete: ((Int) -> ())? ) {
        let alertVC = UIAlertController(title: title, message: message, preferredStyle: preferredStyle)
        for (i, item) in actionTitles.enumerated() {
            let alertAction = UIAlertAction(title: item, style: item == "取消" ? .cancel : .default) { (action) in
                guard let `complete` = complete else { return }
                complete(i)
            }
            alertVC.addAction(alertAction)
        }
        present(alertVC, animated: true, completion: nil)
    }

}
